package com.chuan.thinkingjava.file;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class BufferTest {
	
	private final static String FILE_PATH = "C:\\Users\\Administrator\\Desktop";
	
	public static void main(String[] args) {
		File file = new File(FILE_PATH + File.separator + "test.txt");
		File file1 = new File(FILE_PATH + File.separator + "test1.txt");
		OutputStream out = null;
		InputStream in = null;
		try {
			in = new FileInputStream(file);
			byte[] bytes = new byte[20 * 1024];
			
			out = new FileOutputStream(file1);
			int length;
			while ((length = in.read(bytes, 0, bytes.length)) != -1) {
				out.write(bytes, 0, length);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		
	}
}
